#include <cstdlib>
#include <iostream>
#include "command.h"
#include "./../Character/User.h"
#include "./../Room/room.h"
#include "./../Tools/utility.h"
#include "./../Character/User.h"

using namespace std;

command::command(){};
command::~command(){};

void command::exec(string strCmd)
{
	
	strCmd = utility::string2upper(strCmd);
	if (strCmd == "DUMPUSER")
	{
		u->dump();
	}
	else if (strCmd == "ALLUSER")
	{
		extern map<string, User*> AllUser;
		map<string, User*>::iterator itAllUser;
		for (itAllUser = AllUser.begin(); itAllUser != AllUser.end(); ++itAllUser) {
			cout << "UserName : " << itAllUser->first << endl;
			cout << "Address : " << itAllUser->second << endl;
		}
	}
	else if (strCmd == "DUMPROOM")
	{
		room::dump(u->UserData[ Const.nowRoomID ] );
	}
	else if (strCmd == "L")
	{
		room::MoveInto("school.0001", u);
	}
	
	
	/*
	string strRoomId;
	strRoomId = (*u).UserData[ Const.nowRoomID ];
	room::BroadcastMsg(u, strRoomId, (*u).UserData[ Const.userName ]);
	if  (strCmd == "EXIT")
	{
		(*u).UserProfile.blNeedKickOut = true;
	}
	
	*/
}


void command::setUser(User *inputUser)
{
	u = inputUser;
}


